package cn.com.connected.common.config;/**
 * Created by 邵明生 on 2018/11/22.
 */

import cn.com.connected.vo.MemberVo;
import org.springframework.stereotype.Component;

/**
 * @Author 邵明生
 * @Date
 * @Description
 **/
@Component
public class CurrentData {

    public static ThreadLocal<MemberVo> user = new ThreadLocal<>();

    public static void setUser(MemberVo u) {
        user.set(u);
    }

    public static MemberVo getUser() {
        return user.get();
    }

    public static String getMemberId(){
        if (getUser()==null){
            return null;
        }
        return getUser().getId();
    }

    public static void clear(){
        user.remove();
    }

}
